package com.action.gulimall.order.vo;

import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * @author sl shilun217@qq.com
 * @Deacription 订单结算页详情页vo
 * @date 2021/07/03/14:36
 **/

public class OrderConfirmVo {

    /** 会员收获地址列表 **/
    List<MemberAddressVo> memberAddressVos;

    /** 所有选中的购物项 **/
    List<OrderItemVo> items;

    /** 对应的商品skuId是否有库存 **/
    Map<Long,Boolean> stocks;

    /** 发票记录 **/
    /** 优惠券（会员积分） **/
    private Integer integration;

    /** 防止重复提交的令牌 **/
    private String orderToken;

    /** 购物数量 **/
    public Integer getCount() {
        Integer count = 0;
        if (items != null && items.size() > 0) {
            for (OrderItemVo item : items) {
                count += item.getCount();
            }
        }
        return count;
    }

    /** 应付价格 **/
    //BigDecimal payPrice;
    public BigDecimal getPayPrice() {
        BigDecimal payPrice = BigDecimal.ZERO;
        if (items != null && items.size() > 0) {
            for (OrderItemVo item : items) {
                BigDecimal itemPrice = item.getPrice().multiply(new BigDecimal(item.getCount()));
                payPrice = payPrice.add(itemPrice);
            }
        }
        return payPrice;
    }

    public List<MemberAddressVo> getMemberAddressVos() {
        return memberAddressVos;
    }

    public void setMemberAddressVos(List<MemberAddressVo> memberAddressVos) {
        this.memberAddressVos = memberAddressVos;
    }

    public List<OrderItemVo> getItems() {
        return items;
    }

    public void setItems(List<OrderItemVo> items) {
        this.items = items;
    }

    public Map<Long, Boolean> getStocks() {
        return stocks;
    }

    public void setStocks(Map<Long, Boolean> stocks) {
        this.stocks = stocks;
    }

    public Integer getIntegration() {
        return integration;
    }

    public void setIntegration(Integer integration) {
        this.integration = integration;
    }

    public String getOrderToken() {
        return orderToken;
    }

    public void setOrderToken(String orderToken) {
        this.orderToken = orderToken;
    }
}
